package cvsexample3;

public class EqualityOperator {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		
		/* Output a start message to the console */
		System.out.println("Example 3 - Equality Operators started");
		
		/* Create and initialize a boolean variable */
		boolean bResult = false;
		
		/* Create and initialize two String variables */
		String str1 = new String("HelloWorld");
		String str2 = new String("HelloWorld");
		String str3 = new String("HelloJavaWorld");
		
		/* Output the String variables */
		System.out.println("String str1 = " + str1);
		System.out.println("String str2 = " + str2);
		System.out.println("String str3 = " + str3);
		
		/* Test the equality of str1 and str2 */
		bResult = (str1 == str2);
		System.out.println("str1 == str2: " + bResult);
		
		/* Test the equality of str1 and str3 */
		bResult = (str1 == str3);
		System.out.println("str1 == str3: " + bResult);
		
		/* Test the inequality of str1 and str2 */
		bResult = (str1 != str2);
		System.out.println("str1 != str2: " + bResult);
		
		/* Test the equality of str1 and str3 */
		bResult = (str1 != str3);
		System.out.println("str1 != str3: " + bResult);
		
		/* Use the String class equals() method to test equality of str1 and str2 */
		bResult = str1.equals(str2);
		System.out.println("str1.equals(str2): " + bResult);
		
		/* Use the String class equals() method to test equality of str1 and str3 */
		bResult = str1.equals(str3);
		System.out.println("str1.equals(str3): " + bResult);
		
		/* Output a completed message to the console */
		System.out.println("Example 3 - Equality Operators completed");
	}
}
